QNW_TS_ClientCommand = LuaNet:getInstance().getModule(QNW_TS_Config.name, QNW_TS_Config.debug)

local this = QNW_TS_ClientCommand

this.addCommandHandler("registerTaskCategory", function(_player, _id)
    local taskCategory = _G[_id]
    QNW_TS_ClientCore.registerTaskCategory(taskCategory)
end)

this.addCommandHandler("unregisterTaskCategory", function(_player, _id)
    local taskCategory = _G[_id]
    QNW_TS_ClientCore.unregisterTaskCategory(taskCategory)
end)

this.addCommandHandler("releaseTask", function(_player, _id)
    local task = _G[_id]
    QNW_TS_ClientCore.receiveTask(task)
end)

this.addCommandHandler("sendReward", function(_player, _uuid, _rewards)
    QNW_TS_ClientCore.receiveReward(_uuid, _rewards)
end)

function QNW_TS_ClientCommand.online()
    local player = getPlayer()
    if LuaNet:getInstance().isRunning() then
        this.send("online", player:getModData().dailyTaskUpdateTime)
    else
        QNW_TS_ServerCore.online(player, player:getModData().dailyTaskUpdateTime)
    end
end

function QNW_TS_ClientCommand.addZombie(_x, _y, _z, _count, _type)
    if LuaNet:getInstance().isRunning() then
        this.send("addZombie", _x, _y, _z, _count, _type)
    else
        local player = getPlayer()
        QNW_TS_ServerOther.addZombie(player, _x, _y, _z, _count, _type)
    end
end

function QNW_TS_ClientCommand.randomReward(_task, _type, _count)
    if LuaNet:getInstance().isRunning() then
        this.send("randomReward", _task.uuid, _type, _count)
    else
        local player = getPlayer()
        QNW_TS_ServerOther.randomReward(player, _task.uuid, _type, _count)
    end
end
